{include file='public/header'}
<body>
	<div class="sectionY">
		<a href="javascript:history.back();">
			<img src="__PUBLIC__/home/images/a19.png" alt="" class="a1">
		</a>
		<p class="p1">我的收藏</p>
		<a href="javascript:;" class="a3" id="del_btn">操作</a>
	</div>
	<div class="kong1" style=""></div>
	<div class="q_section3">
		<ul class="clearfix">
		</ul>
		<div style="line-height: 25px; text-align: center; color: #868686;" onclick="getMore()" class="more">
			<span style="width: 100%;">--点击查看更多--</span>
		</div>
	</div>
	<div class="kong"></div>
	<div class="shou_foot">
		<div class="left">
			<img src="__PUBLIC__/home/images/a33.png" alt="" class="img1">
			<img src="__PUBLIC__/home/images/a34.png" alt="" class="img2">
			<span class="s1">全选</span>
		</div>
		<div class="right">
			<a href="javascript:;" onclick="delCollect()">删除</a>
		</div>
	</div>
</body>
<script>
	$(function(){
		$(".img1").on("click", function () {
			$(this).hide().siblings(".img2").show()
			$(".im2").show();
			$(".im1").hide();
		})
		$(".img2").on("click", function () {
			$(this).hide().siblings(".img1").show()
			$(".im2").hide();
			$(".im1").show();
		})
		$("ul").on("click", ".im1", function () {
			$(this).hide();
			$(this).siblings(".im2").show();
		})
		$("ul").on("click", ".im2", function () {
			$(this).hide();
			$(this).siblings(".im1").show();
		})
		$("#del_btn").click(function(){
			let txt = $(this).text();
			if(txt == "操作"){
				$(".small").show();
				$(".big").css("width","90%");
				$(".shou_foot").show()
				$(this).text("保存")
			}else{
				$(".small").hide();
				$(".big").css("width","100%");
				$(".shou_foot").hide()
				$(this).text("操作")
			}
		})
		getMore();
	})
	var p=1,page_num=20,is_end=false;
	function getMore() {
		if(is_end){
			return;
		}
		let index = modal.loading();
		$.post(location.href, {page:p, page_num:page_num}, function (res) {
			p++;
			let data = res.result_data;
			modal.close(index);
			let _li = '';
			$.each(data, function (i,v) {
				_li += '<li class="clearfix">\n' +
						'\t\t\t\t<div class="small" data-gc_id="'+v.id+'">\n' +
						'\t\t\t\t\t<img src="__PUBLIC__/home/images/a33.png" alt="" class="im1">\n' +
						'\t\t\t\t\t<img src="__PUBLIC__/home/images/a34.png" alt="" class="im2">\n' +
						'\t\t\t\t</div>\n' +
						'\t\t\t\t<div class="big clearfix">\n' +
						'\t\t\t\t\t<div class="logo">\n' +
						'\t\t\t\t\t\t<a href="javascript:;"><img src="'+v.img_url+'" alt=""></a>\n' +
						'\t\t\t\t\t</div>\n' +
						'\t\t\t\t\t<div class="center">\n' +
						'\t\t\t\t\t\t<a href="javascript:;">\n' +
						'\t\t\t\t\t\t\t<p class="p1 chao">'+v.title+'</p>\n' +
						'\t\t\t\t\t\t\t<p class="p2"><span class="s1">'+v.brand_title+'</span></p>\n' +
						'\t\t\t\t\t\t</a>\n' +
						'\t\t\t\t\t\t<p class="p3 clearfix">\n' +
						'\t\t\t\t\t\t\t<span class="s1">￥'+v.price+'</span>\n' +
						'\t\t\t\t\t\t</p>\n' +
						'\t\t\t\t\t</div>\n' +
						'\t\t\t\t</div>\n' +
						'\t\t\t</li>';
			})
			$("ul").append(_li);
			if(data.length<page_num){
				$(".more").find("span").text("--我是有底线的--");
				is_end=true;
			}
		});
		
	}
	//删除收藏
	function delCollect() {
		let selected = $(".im2:visible");
		if(selected.length==0){
			modal.msg("你还未选择删除的收藏");
			return ;
		}
		modal.confirm("确定删除？","确定", function () {
			let id_arr = new Array();
			$.each(selected, function (i,v) {
				id_arr.push($(v).parent().data("gc_id"));
			})
			let index = modal.loading();
			$.post("{:url('delCollect')}", {ids:id_arr.join(",")}, function (res) {
				modal.close(index);
				modal.msg(res.result_info);
				if(res.result_code == 0){
					$(".im2:visible").parent().parent().remove();
				}
			});
		})
	}
</script>

</html>